package com.trade.dao.listener;

import java.util.Map;

import net.esper.client.UpdateListener;
import net.esper.event.EventBean;

import org.hibernate.Session;

import com.trade.dao.impl.*;
import com.trade.dao.IEquityDAO;
import com.trade.data.EquityIntradayDataVO;
import com.trade.data.GainEventVO;
import com.trade.data.HistoricalDataVO;
import com.trade.data.IndexIntradayDataVO;
import com.trade.data.LossEventVO;

public class PriceGainOrLossUpdateListener extends BaseDAO implements UpdateListener {

	Session session = null;
	private static IEquityDAO equityDAO;

	public static void setEquityDAO(IEquityDAO pEquityDAO) {
		equityDAO = pEquityDAO;
	}

	public void update(EventBean[] newData, EventBean[] oldData) {
		if (newData[0].getUnderlying() instanceof Map) {
			System.out.println("Stock Average Gain Or Loss : "+newData[0].getUnderlying());
		}
		if (newData[0].getUnderlying() instanceof GainEventVO) {
			System.out.println("Stock Gain : "+newData[0].getUnderlying());
		}else if (newData[0].getUnderlying() instanceof LossEventVO) {
			System.out.println("Stock Loss : "+newData[0].getUnderlying());
		}
	}
}
